package com.lkd.service.impl;

import com.lkd.mapper.ReportMapper;
import com.lkd.service.ReportService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
@RequiredArgsConstructor
public class ReportServiceImpl implements ReportService {
    private final ReportMapper reportMapper;

    @Override
    // 订单数量
    public Integer orderCount(LocalDateTime start, LocalDateTime end) {
        return reportMapper.orderCount(start, end);
    }

    @Override
    // 销售额统计
    public Double orderAmount(LocalDateTime start, LocalDateTime end) {
        Double sales = reportMapper.orderAmount(start, end);
        if (sales == null || sales.isNaN())
            return 0d;
        return sales;
    }
}
